/**
 * BaseSession.java
 *2014年4月19日下午3:12:33
 *LINKT
 */
package com.bh.db.util;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * @author LINKT
 *
 */
public class BaseSessionFactory {

        private static SqlSessionFactory sessionFactory;
        private static Reader reader;
        
        static{
                try {
                        reader=Resources.getResourceAsReader("Configuration.xml");
                        sessionFactory = new SqlSessionFactoryBuilder().build(reader);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                
        }
        
        public static SqlSessionFactory getSessionFactory() {
                return sessionFactory;
        }
        
        public static SqlSession getSession() {
                return sessionFactory.openSession();
        }
        public static SqlSession getSession(boolean autoCommit) {
                return sessionFactory.openSession(autoCommit);
        }
        
        /**
         * @param args
         */
        public static void main(String[] args) {
                // TODO Auto-generated method stub

        }

}
